---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[60], line 52
     39 fig = make_subplots(
     40     rows=2, cols=2,
     41     subplot_titles=[
   (...)
     47     specs=[[{'type': 'bar'}, {'type': 'bar'}], [{'type': 'bar'}, {'type': 'bar'}]]
     48 )
     50 # Generate each individual bar chart
     51 charts = [
---> 52     create_ratio_bar_chart(worldometer_data, 'TotalDeaths', 'TotalCases', 'Death to Confirmed Cases by Country (Top 50)'),
     53     create_ratio_bar_chart(worldometer_data, 'TotalDeaths', 'TotalRecovered', 'Death to Recovered Cases by Country (Top 50)'),
     54     create_ratio_bar_chart(worldometer_data, 'TotalTests', 'TotalCases', 'Tests to Confirmed Cases by Country (Top 50)'),
     55     create_ratio_bar_chart(worldometer_data, 'Serious,Critical', 'TotalDeaths', 'Serious/Critical to Deaths by Country (Top 50)')
     56 ]
     58 # Add each chart to the subplot
     59 for i, chart in enumerate(charts, start=1):

Cell In[60], line 25, in create_ratio_bar_chart(data, numerator_col, denominator_col, title, top_n)
     22 data_sorted = data_sorted.sort_values(by='Ratio', ascending=False).head(top_n)
     24 # Create the bar chart
---> 25 bar_chart = px.bar(data_sorted, 
     26                     x='Country/Region', 
     27                     y='Ratio',
     28                     title=title,
     29                     labels={'Ratio': f'{numerator_col} to {denominator_col} Ratio'},
     30                     text='Ratio',  # Display the ratio value on top of bars
     31                     # color='Ratio',  # Color by the ratio to emphasize differences
     32                     color=col,
     33                     # color_discrete_sequence=['#FF5733'],  # Set a single color to remove color scale
     34                     range_y=[0, data_sorted['Ratio'].max() + 0.1])
     36 return bar_chart

File ~/anaconda3/lib/python3.12/site-packages/plotly/express/_chart_types.py:373, in bar(data_frame, x, y, color, pattern_shape, facet_row, facet_col, facet_col_wrap, facet_row_spacing, facet_col_spacing, hover_name, hover_data, custom_data, text, base, error_x, error_x_minus, error_y, error_y_minus, animation_frame, animation_group, category_orders, labels, color_discrete_sequence, color_discrete_map, color_continuous_scale, pattern_shape_sequence, pattern_shape_map, range_color, color_continuous_midpoint, opacity, orientation, barmode, log_x, log_y, range_x, range_y, text_auto, title, template, width, height)
    325 def bar(
    326     data_frame=None,
    327     x=None,
   (...)
    367     height=None,
    368 ) -> go.Figure:
    369     """
    370     In a bar plot, each row of `data_frame` is represented as a rectangular
    371     mark.
    372     """
--> 373     return make_figure(
    374         args=locals(),
    375         constructor=go.Bar,
    376         trace_patch=dict(textposition="auto"),
    377         layout_patch=dict(barmode=barmode),
    378     )

File ~/anaconda3/lib/python3.12/site-packages/plotly/express/_core.py:2117, in make_figure(args, constructor, trace_patch, layout_patch)
   2114 layout_patch = layout_patch or {}
   2115 apply_default_cascade(args)
-> 2117 args = build_dataframe(args, constructor)
   2118 if constructor in [go.Treemap, go.Sunburst, go.Icicle] and args["path"] is not None:
   2119     args = process_dataframe_hierarchy(args)

File ~/anaconda3/lib/python3.12/site-packages/plotly/express/_core.py:1513, in build_dataframe(args, constructor)
   1510     args["color"] = None
   1511 # now that things have been prepped, we do the systematic rewriting of `args`
-> 1513 df_output, wide_id_vars = process_args_into_dataframe(
   1514     args, wide_mode, var_name, value_name
   1515 )
   1517 # now that `df_output` exists and `args` contains only references, we complete
   1518 # the special-case and wide-mode handling by further rewriting args and/or mutating
   1519 # df_output
   1521 count_name = _escape_col_name(df_output, "count", [var_name, value_name])

File ~/anaconda3/lib/python3.12/site-packages/plotly/express/_core.py:1234, in process_args_into_dataframe(args, wide_mode, var_name, value_name)
   1232         if argument == "index":
   1233             err_msg += "\n To use the index, pass it in directly as `df.index`."
-> 1234         raise ValueError(err_msg)
   1235 elif length and len(df_input[argument]) != length:
   1236     raise ValueError(
   1237         "All arguments should have the same length. "
   1238         "The length of column argument `df[%s]` is %d, whereas the "
   (...)
   1245         )
   1246     )

ValueError: Value of 'color' is not the name of a column in 'data_frame'. Expected one of ['Country/Region', 'Continent', 'Population', 'TotalCases', 'NewCases', 'TotalDeaths', 'NewDeaths', 'TotalRecovered', 'NewRecovered', 'ActiveCases', 'Serious,Critical', 'Tot Cases/1M pop', 'Deaths/1M pop', 'TotalTests', 'Tests/1M pop', 'WHO Region', 'Ratio'] but received: 2